home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performDynamicsConnect.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.1 KB  |  157 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April, 1997
  22. //  Author:         Carol Levy
  23. //
  24. //  Description:
  25. //      This script contains code to connect fields/emitters/
  26. //        collisions to objects.
  27. //        performDynamicsConnect is called when a user selects
  28. //      a Connect menu item.
  29. //
  30. //  Input Arguments to performDynamics():
  31. //        int $whichConnection -- 1 = field; 2 = emitter; 3 = collision
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. //
  37. //  ========== performDynamicsConnect ==========
  38. //
  39. //  SYNOPSIS
  40. //        Issue the appropriate connectDynamic command.
  41. //
  42. global proc performDynamicsConnect( int $whichConnection)
  43. {
  44.     string $selected[] = `ls -sl`;
  45.     string $cmd;
  46.     int $i;
  47.     string $cmdStart = "connectDynamic";
  48.     int $len = size($selected);
  49.     int $numConnections =  $len - 1;
  50.  
  51.     if ($numConnections < 1)
  52.     {
  53.         string $theMsg;
  54.         string $theType;
  55.         switch ($whichConnection) 
  56.         {
  57.             case 1: {
  58.                 $theType = "field";
  59.                 
  60.                 break;
  61.             }
  62.             case 2: {
  63.                 $theType = "emitter";
  64.                 break;
  65.             }
  66.             case 3: {
  67.                 $theType = "collision";
  68.                 break;
  69.             }
  70.         }
  71.  
  72.         if ($numConnections  == -1)
  73.         {
  74.             $theMsg = "Nothing has been selected; ";
  75.         }
  76.         else if ($numConnections == 0)
  77.         {
  78.             $theMsg = "Only one object has been selected; ";
  79.         }
  80.         warning($theMsg + "select first the objects to be connected then the "+$theType);
  81.         return;
  82.     }
  83.  
  84.     // Create the command args for the selected command, and
  85.     // issue the command.
  86.     //
  87.     switch ($whichConnection) 
  88.     {
  89.         case 1: {
  90.             string $field, $objects;
  91.             string $fields[] = `ls -sl -typ field`;
  92.             int $numFields = size($fields);
  93.             if($numFields > 0) {
  94.                 for ($i = 0; $i < $len; $i++) {
  95.                     string $isField[] = `ls -type field $selected[$i]`;
  96.                     if (0 == size($isField)) {
  97.                         $objects += (" " + $selected[$i]);
  98.                     }
  99.                 }
  100.                 for ($field in $fields) {
  101.                     $cmd += ($cmdStart + " -f " + $field + $objects +"; ");
  102.                     $cmd += "; ";
  103.                 }
  104.             } else {
  105.                 // if there's no dull normal fields selected...
  106.                 // see if there's any fluids - and use them as fields instead
  107.                 string $fluids[];
  108.                 int $numFluids = 0;
  109.                 for ($i = 0; $i < $len; $i++) {
  110.                     string $fluidName = getFluidShape($selected[$i]);
  111.                     if (0 == size($fluidName)) {
  112.                         $objects += (" " + $selected[$i]);
  113.                     } else {
  114.                         $fluids[$numFluids++]  = $fluidName;
  115.                     }
  116.                 }
  117.                 for ($fluid in $fluids) {
  118.                     $cmd += ($cmdStart + " -f " + $fluid + $objects +"; ");
  119.                     $cmd += "; ";
  120.                 }
  121.  
  122.             }
  123.             break;
  124.         }            
  125.         case 2:
  126.  
  127.             $cmd = $cmdStart + " -em " + $selected[$numConnections];
  128.             break;
  129.  
  130.         case 3:
  131.             // Collision.  Must check whether last two
  132.             // objects in selection list are the two parts of a
  133.             // soft body.  If so, use the geometry's name (which
  134.             // will be second to last in list).  The particle shape
  135.             // will be last.  
  136.             //
  137.             string $softQuery = "soft -q " + $selected[$len-1] + 
  138.                                 " " + $selected[$len-2];
  139.             int $leadIsSoft = eval( $softQuery );
  140.             if ($leadIsSoft)
  141.             {
  142.                 $numConnections = $numConnections - 1;
  143.             }
  144.             $cmd = $cmdStart + " -c " + $selected[$numConnections];
  145.             break;
  146.     }
  147.  
  148.     if ($whichConnection != 1) {
  149.         for ($i = 0; $i < $numConnections; $i++) 
  150.         {
  151.             $cmd = $cmd + " " + $selected[$i];
  152.         }
  153.     }
  154.     evalEcho ($cmd);
  155. }
  156.  
  157.